package edu.scau.mis.pos.service.impl;

import edu.scau.mis.pos.domain.VipPackage;
import edu.scau.mis.pos.mapper.VipPackageMapper;
import edu.scau.mis.pos.service.IVipPackageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * (VipPackage)表服务实现类
 *
 * @author CJW
 * @since 2024-04-18 17:39:39
 */
@Service("vipPackageService")
public class VipPackageServiceImpl implements IVipPackageService {
    @Resource
    private VipPackageMapper vipPackageMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param packageId 主键
     * @return 实例对象
     */
    @Override
    public VipPackage selectById(Long packageId) {
        return this.vipPackageMapper.selectById(packageId);
    }

    /**
     * 查询指定行
     *
     * @param vipPackage 筛选条件
     * @return 查询结果
     */
    @Override
    public List<VipPackage> selectList(VipPackage vipPackage) {
        return this.vipPackageMapper.selectList(vipPackage);
    }

    /**
     * 新增数据
     *
     * @param vipPackage 实例对象
     * @return 实例对象
     */
    @Override
    public VipPackage insert(VipPackage vipPackage) {
        vipPackage.setCreateTime(new Date());
        this.vipPackageMapper.insert(vipPackage);
        return vipPackage;
    }

    /**
     * 修改数据
     *
     * @param vipPackage 实例对象
     * @return 实例对象
     */
    @Override
    public VipPackage update(VipPackage vipPackage) {
        vipPackage.setUpdateTime(new Date());
        this.vipPackageMapper.update(vipPackage);
        return this.selectById(vipPackage.getPackageId());
    }

    /**
     * 通过主键批量删除数据
     *
     * @param packageId 主键
     * @return 影响记录数
     */
    @Override
    public int deleteByIds(Long[] packageId) {
        return this.vipPackageMapper.deleteByIds(packageId);
    }
}
